﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Drawing;

namespace ZhimeiSoft.CharmManager.DOL
{
    /// <summary>
    /// 预约表
    /// </summary>
    public class DBEntityReservation : DBEntityBase
    {
        public override string GetTableName()
        {
            return "RESERVATION";
        }
        public DBEntityReservation()
            : base()
        {
        }
        public DBEntityReservation(DataRow drRow)
        {
            this.RESERVATIONID = Convert.ToInt32(drRow[DBEntityReservation.FieldName.RESERVATIONID]);
            this.RESERVATIONTIME = Convert.ToDateTime(drRow[DBEntityReservation.FieldName.RESERVATIONTIME]);
	        this.RWORKSTARTTIME = Convert.ToDateTime(drRow[DBEntityReservation.FieldName.RWORKSTARTTIME]);
	        this.RWORKENDTIME = Convert.ToDateTime(drRow[DBEntityReservation.FieldName.RWORKENDTIME]);
	        this.RSTATE = drRow[DBEntityReservation.FieldName.RSTATE].ToString();
	        this.RMEMO = drRow[DBEntityReservation.FieldName.RMEMO].ToString();
	        this.CUSTOMERID = Convert.ToInt32(drRow[DBEntityReservation.FieldName.CUSTOMERID]);
        }
        /// <summary>
        /// 会员预约表ID
        /// </summary>
        public int RESERVATIONID {get; set;}
        /// <summary>
        /// 预约到店时间
        /// </summary>
	    public DateTime RESERVATIONTIME {get; set;}
        /// <summary>
        /// 操作开始时间
        /// </summary>
        public DateTime RWORKSTARTTIME {get; set;}
        /// <summary>
        /// 操作结束时间
        /// </summary>
    	public DateTime RWORKENDTIME {get; set;}
        /// <summary>
        /// 预约完成C0A 预约过期 C0D 预约进行中 C0N
        /// </summary>
	    public string RSTATE {get; set;}
        /// <summary>
        /// 预约信息
        /// </summary>
	    public string RMEMO {get; set;}
        /// <summary>
        /// 会员ID
        /// </summary>
        public int CUSTOMERID { get; set; }
        /// <summary>
        /// 字段名称
        /// </summary>
        public static class FieldName
        {
            /// <summary>
            /// 会员预约表ID
            /// </summary>
            public const string RESERVATIONID = "RESERVATIONID";
            /// <summary>
            /// 预约到店时间
            /// </summary>
	        public const string RESERVATIONTIME = "RESERVATIONTIME";
            /// <summary>
            /// 操作开始时间
            /// </summary>
	        public const string RWORKSTARTTIME = "RWORKSTARTTIME";
            /// <summary>
            /// 操作结束时间
            /// </summary>
	        public const string RWORKENDTIME = "RWORKENDTIME";
            /// <summary>
            /// 预约完成C0A 预约过期 C0D 预约进行中 C0N
            /// </summary>
	        public const string RSTATE = "RSTATE";
            /// <summary>
            /// 预约信息
            /// </summary>
	        public const string RMEMO = "RMEMO";
            /// <summary>
            /// 会员ID
            /// </summary>
            public const string CUSTOMERID = "CUSTOMERID";
        }
        /// <summary>
        /// 预约完成C0A 预约过期 C0D 预约进行中 C0N
        /// </summary>
        public static class ENUM_RSTATE
        {
            /// <summary>
            /// 预约完成 C0A 
            /// </summary>
            public const string C0A = "C0A";
            /// <summary>
            /// 预约过期 C0D
            /// </summary>
            public const string C0D = "C0D";
            /// <summary>
            /// 预约进行中 C0N
            /// </summary>
            public const string C0N = "C0N";
            /// <summary>
            /// 预约取消
            /// </summary>
            public const string C0E = "C0E";
            /// <summary>
            /// 预约完成 C0A 
            /// </summary>
            public const string C0A_CHINESE = "预约完成";
            /// <summary>
            /// 预约过期 C0D
            /// </summary>
            public const string C0D_CHINESE = "预约过期";
            /// <summary>
            /// 预约进行中 C0N
            /// </summary>
            public const string C0N_CHINESE = "预约进行中";
            /// <summary>
            /// 预约取消
            /// </summary>
            public const string C0E_CHINESE = "预约取消";
            /// <summary>
            /// 根据枚举值返回中文
            /// </summary>
            /// <param name="cState">枚举值</param>
            /// <returns>返回中文</returns>
            public static string EnumStrToChineseStr(string cState)
            {
                string[] serchStr = new string[] { C0A, C0D, C0N, C0E};
                string[] sReturnStr = new string[] { C0A_CHINESE, C0D_CHINESE, C0N_CHINESE, C0E_CHINESE};
                return DBEntityBase.GetStrReturnStr(cState, serchStr, sReturnStr);
            }
            /// <summary>
            /// 根据中文返回枚举值
            /// </summary>
            /// <param name="chineseStr">中文</param>
            /// <returns>返回枚举字符串</returns>
            public static string ChineseStrToEnumStr(string chineseStr)
            {
                string[] serchStr = new string[] { C0A_CHINESE, C0D_CHINESE, C0N_CHINESE, C0E_CHINESE};
                string[] sReturnStr = new string[] { C0A, C0D, C0N, C0E};
                return DBEntityBase.GetStrReturnStr(chineseStr, serchStr, sReturnStr);
            }
        }
        /// <summary>
        /// 自定义函数类
        /// </summary>
        public static class CUSTOMFUNC
        {
            /// <summary>
            /// 根据枚举值转换为显示字符串
            /// </summary>
            /// <param name="state"></param>
            /// <returns></returns>
            public static string GetResverationStateStr(string state)
            {
                if (DBEntityReservation.ENUM_RSTATE.C0A.Equals(state))
                {
                    return "完成";
                }
                else if (DBEntityReservation.ENUM_RSTATE.C0D.Equals(state))
                {
                    return "过期";
                }
                else if (DBEntityReservation.ENUM_RSTATE.C0N.Equals(state))
                {
                    return "进行";
                }
                else if (DBEntityReservation.ENUM_RSTATE.C0E.Equals(state))
                {
                    return "取消";
                }
                return "";
            }
            /// <summary>
            /// 根据状态值返回颜色
            /// </summary>
            /// <param name="stateChinese">完成 (浅蓝色)、 过期 (钱粉色)、 进行 (浅绿色)</param>
            /// <returns></returns>
            public static  Color GetColorResverationState(string stateChinese)
            {
                Color cResult;
                if (stateChinese.Equals("完成"))
                {
                    return cResult = Color.FromArgb(155, 215, 232);
                } if (stateChinese.Equals("过期"))
                {
                    return cResult = Color.FromArgb(234, 183, 149);
                }
                else if (stateChinese.Equals("进行"))
                {
                    return cResult = Color.FromArgb(131, 217, 177);
                }
                else if (stateChinese.Equals("取消"))
                {
                    return cResult = Color.FromArgb(228, 215, 41);
                }
                return Color.White;
            }


            /// <summary>
            /// 根据分钟获取4分之一最近的
            /// </summary>
            /// <param name="minute"></param>
            /// <returns></returns>
            public static int GetRoundMinute(int minute)
            {
                if (minute >= 0 && minute <= 15)
                {
                    return 15;
                }
                else if (minute > 15 && minute <= 30)
                {
                    return 30;
                }
                else if (minute > 30 && minute <= 45)
                {
                    return 45;
                }
                else if (minute > 45 && minute <= 59)
                {
                    return 0;
                }
                return 0;
            }
        }
    }
}
